package com.bykj.property.mapper.provider;

import com.bykj.property.controller.vo.request.PmUnitPageRequest;
import com.bykj.property.controller.vo.request.PmVillagePageRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.jdbc.SQL;

/**
 * @author yiming
 * @title: PmVillageSql
 * @projectName property
 * @description: TODO
 * @date 2019/6/3017:27
 */
public class PmVillageSql {
    public String getSql(PmVillagePageRequest pageRequest){
        return new SQL() {
            {
                SELECT("*");
                FROM("pm_village");

                if(!StringUtils.isEmpty(pageRequest.getViNumber())) {
                    pageRequest.setViNumber("%"+pageRequest.getViNumber()+"%");
                    WHERE("vi_number like #{viNumber}");
                }
                if(!StringUtils.isEmpty(pageRequest.getViName())) {
                    pageRequest.setViName("%"+pageRequest.getViName()+"%");
                    WHERE("vi_name like #{viName}");
                }
            }
        }.toString();

    }
}
